Content

1 Code overview

One of the strategies that was considered was exponential moving average (EMA). It is one of the most basic strategies to implement, thus the results are not the best to expect to get. A moving average (MA) is a widely used technical indicator that smooths out price trends by filtering out the noise from random short-term price fluctuations. It is important to note that moving average strategy is mostly beneficial for short-term time series and the ones that do not have drastic increases/decreases over the time. In the results you will see that this method is nothing to compare to total returns for some instruments.

1.1 Definitions and investment from portfolio strategy

  • Total returns – a measure of the performance of an asset, usually a share or bond, over a period of time. It indicates the amount of money that could be saved starting from investment date for some period of time with no strategies included.
  • Strategy returns – a measure of the performance of an asset, usually a share or bond, over a period of time with a specific strategy.

In our case, we are assuming that for each instrument 5% of total portfolio ($1000 in the beginning) is being invested every time when the strategy tells to invest. It is a safe strategy to not lose all money by investing all of the gained amount. Example: you invest $50 on 2012-01-01 when strategy says to invest. Then on 2012-03-01 the strategy shows that money need to be pulled out with the growth of $70 ($20 gained). Since our portfolio was $1000, now we have $1020. The next time when strategy says to invest, we are investing another 5% from the total portfolio ($1020 this time) which is $51 and continue the same procedure.

Another better scenario (not coded) is to take out not the whole amount of money but 10% and invest 30% when the time comes. There are many different ways to deal with investments.

Please note that in this solution the total portfolio was used for every instrument. To get optimal portfolio split for all instruments it require a lot more time to think of different ways to split the amount and monitor its returns, especially when we have different time series for instruments here.

1.2 Understanding the code structure

The code is written in a very common coding manner:

  • 000_run.R – file that should be run to get results, plots and best fits for MA strategy.
  • 01_setup.R – libraries that need to be loaded. There are extra libraries since the starting idea was to use neural networks and more advanced statistics but ended up implementing simpler strategy.
  • 02_functions.R – functions that are used to create MA strategy.
  • 03_strategies.R – a script where functions are called in the correct order with the correct data.
  • 04_best_strategy.R – a script where optimal moving averages could be found. This script should be run one to get optimal MAs. Since the assignment was done pretty fast, function that is looking for optimal points is very slow due to nested for loops. In order to get better experience, function should be rewritten. On the other hand, if a function get_returns_new is optimized, running time should increase significantly.
  • documentation_and_results.Rmd – an overview of the strategy selected, code logic and results presented.

Please note that most of the data frame manipulations are done with data.table package instead of base or dplyr to optimize the running time as much as possible.

1.3 Data aggregation

The data set is aggregated per instrument daily with the logic for columns as follows:

  • open – taking the first record of the day;
  • high – taking the max record of the day;
  • low – taking the min record of the day;
  • close – taking the last record of the day;
  • volume – summing all records per day.

2 Results

Here are going to be presented results for each instrument.

For each instrument the first graph represents trends of the instrument using candle sticks (turn it off to get a smoother view by pressing ‘Stocks’ in the Variables section), selected optimal moving averages for short period of time and Buy/Sell points for our strategy. Second graph represents returns for the total period of time since the first investment of our total portfolio ($1000 as mentioned before). Note that the final number does not represent what is the total saved money is. It indicates how our strategy performs in a graphical manner. Please see the tables below at the last number of Strategy_returns to see the number that is saved.

The gaps between Strategy returns in the second graph is intended to be shown, it is because in the gaps between when strategy says to invest and when it is time to take the money out there is nothing happening with our money because we took all of it out.

Simply saying, the higher the Strategy returns line is, the more money we gain. If the red line is over the blue one, it means that our strategy works better than total returns strategy.

Moreover, please not that there was taken a short term moving averages optimization function. The amount of iteration for each instrument was taken 40 days. For very poorly performing instruments an additional graph is presented what would happen if we would choose long term moving averages (instruments 1004, 1005, 1006).

2.1 Instrument 1001

Investment_from Total_portfolio Investment_percent investment_money total_saved Strategy_returns
2018-04-12 1000.0000 0.05 50.00000 68.35268 0.0000000
2018-05-09 1018.3527 0.05 50.91763 46.91793 18.3526751
2018-06-07 1014.3530 0.05 50.71765 44.56894 14.3529669
2018-07-10 1008.2043 0.05 50.41021 41.93252 8.2042563
2018-07-31 999.7266 0.05 49.98633 41.02562 -0.2734372
2018-09-06 990.7659 0.05 49.53829 49.75897 -9.2341463
2018-10-05 990.9865 0.05 49.54933 51.85979 -9.0134724
2018-10-07 993.2970 0.05 49.66485 42.14074 -6.7030091
2018-10-12 985.7729 0.05 49.28864 40.91765 -14.2271194
2018-11-14 977.4019 0.05 48.87009 57.05836 -22.5981087
2019-01-13 985.5902 0.05 49.27951 48.92333 -14.4098451
2019-01-21 985.2340 0.05 49.26170 49.72425 -14.7660272
2019-02-27 985.6965 0.05 49.28483 85.59312 -14.3034760
2019-04-19 1022.0048 0.05 51.10024 60.41100 22.0048179
2019-06-06 1031.3156 0.05 51.56578 47.87521 31.3155782
2019-06-28 1027.6250 0.05 51.38125 50.25224 27.6250070
2019-09-12 1026.4960 0.05 51.32480 40.98718 26.4959920
2019-09-24 1016.1584 0.05 50.80792 46.03981 16.1583715
2019-10-16 1011.3903 0.05 50.56951 48.98809 11.3902622
2019-11-20 1009.8088 0.05 50.49044 47.21200 9.8088418
2019-12-03 1006.5304 0.05 50.32652 84.55612 6.5304041
2020-02-20 1040.7600 0.05 52.03800 56.25068 40.7599992
2020-04-16 1044.9727 0.05 52.24863 118.92799 44.9726770
2020-06-15 1111.6520 0.05 55.58260 56.61304 111.6520307
2020-06-22 1112.6825 0.05 55.63412 54.00712 112.6824680
2020-06-28 1111.0555 0.05 55.55277 93.62850 111.0554640
2020-08-13 1149.1312 0.05 57.45656 53.13059 149.1311861
2020-10-07 1144.8052 0.05 57.24026 57.89463 144.8052186
2020-10-27 1145.4596 0.05 57.27298 83.64579 145.4595864
2020-12-09 1171.8324 0.05 58.59162 58.39348 171.8324001
2020-12-24 1171.6343 0.05 58.58171 130.05239 171.6342624
2021-01-28 1243.1049 0.05 62.15525 184.71134 243.1049371
2021-03-12 1365.6610 0.05 68.28305 NA 365.6610272
  • Total returns with no strategy = 170.33$.
  • Total returns with strategy = 365.66$.

2.2 Instrument 1002

Investment_from Total_portfolio Investment_percent investment_money total_saved Strategy_returns
2014-04-01 1000.0000 0.05 50.00000 48.48307 0.0000000
2014-04-08 998.4831 0.05 49.92415 48.02673 -1.5169326
2014-05-07 996.5856 0.05 49.82928 51.01822 -3.4143604
2014-07-10 997.7746 0.05 49.88873 49.71094 -2.2254243
2014-09-25 997.5968 0.05 49.87984 52.65142 -2.4032095
2014-12-10 1000.3684 0.05 50.01842 48.31836 0.3683743
2015-01-07 998.6683 0.05 49.93342 61.08967 -1.3316848
2015-04-13 1009.8246 0.05 50.49123 49.71433 9.8245673
2015-07-29 1009.0477 0.05 50.45238 47.06644 9.0476668
2015-08-06 1005.6617 0.05 50.28309 49.30372 5.6617228
2015-10-23 1004.6824 0.05 50.23412 48.45390 4.6823544
2015-11-05 1002.9021 0.05 50.14511 48.53352 2.9021326
2015-11-17 1001.2906 0.05 50.06453 49.57421 1.2905506
2015-12-24 1000.8002 0.05 50.04001 63.62299 0.8002346
2016-04-08 1014.3832 0.05 50.71916 50.56127 14.3832145
2016-05-23 1014.2253 0.05 50.71127 48.82193 14.2253212
2016-06-07 1012.3360 0.05 50.61680 51.39239 12.3359826
2016-08-02 1013.1116 0.05 50.65558 53.64316 13.1115765
2016-10-28 1016.0992 0.05 50.80496 50.64713 16.0991624
2016-12-05 1015.9413 0.05 50.79707 47.89437 15.9413306
2017-02-01 1013.0386 0.05 50.65193 49.66532 13.0386357
2017-04-13 1012.0520 0.05 50.60260 49.93521 12.0520268
2017-04-28 1011.3846 0.05 50.56923 45.49432 11.3846364
2017-10-10 1006.3097 0.05 50.31549 50.86476 6.3097243
2017-10-31 1006.8590 0.05 50.34295 48.41087 6.8590031
2018-01-08 1004.9269 0.05 50.24635 52.56704 4.9269249
2018-03-19 1007.2476 0.05 50.36238 51.13930 7.2476221
2018-05-10 1008.0245 0.05 50.40123 49.93580 8.0245369
2018-07-23 1007.5591 0.05 50.37796 58.63940 7.5591059
2018-10-12 1015.8205 0.05 50.79103 47.58449 15.8205490
2018-10-25 1012.6140 0.05 50.63070 47.56415 12.6140156
2018-12-18 1009.5475 0.05 50.47737 49.64509 9.5474654
2019-02-08 1008.7152 0.05 50.43576 50.51636 8.7151864
2019-04-26 1008.7958 0.05 50.43979 54.45772 8.7957837
2019-08-28 1012.8137 0.05 50.64069 47.77206 12.8137181
2019-09-20 1009.9451 0.05 50.49725 50.23624 9.9450910
2019-11-08 1009.6841 0.05 50.48420 47.14253 9.6840746
2020-02-27 1006.3424 0.05 50.31712 75.47568 6.3424034
2020-06-24 1031.5010 0.05 51.57505 66.64192 31.5009634
2020-09-16 1046.5678 0.05 52.32839 50.35034 46.5678315
2020-12-16 1044.5898 0.05 52.22949 98.75473 44.5897823
2021-02-12 1091.1150 0.05 54.55575 74.00353 91.1150269
2021-03-31 1110.5628 0.05 55.52814 45.40531 110.5628047
2021-05-05 1100.4400 0.05 55.02200 209.91299 100.4399756
2021-07-08 1255.3310 0.05 62.76655 58.45423 255.3309636
2021-09-22 1251.0186 0.05 62.55093 57.40226 251.0186479
2021-10-25 1245.8700 0.05 62.29350 57.55327 245.8699722
2021-11-29 1241.1297 0.05 62.05649 54.97876 241.1297410
2022-02-24 1234.0520 0.05 61.70260 51.35705 234.0520154
2022-03-07 1223.7065 0.05 61.18532 53.24826 223.7064674
2022-04-12 1215.7694 0.05 60.78847 58.72951 215.7694051
2022-06-06 1213.7104 0.05 60.68552 59.29541 213.7104408
2022-06-10 1212.3203 0.05 60.61602 NA 212.3203301
  • Total returns with no strategy = -15.21$.
  • Total returns with strategy = 212.32$.

2.3 Instrument 1003

Investment_from Total_portfolio Investment_percent investment_money total_saved Strategy_returns
2005-04-26 1000.0000 0.05 50.00000 48.46319 0.0000000
2005-05-09 998.4632 0.05 49.92316 42.67339 -1.5368122
2005-08-22 991.2134 0.05 49.56067 48.48675 -8.7865855
2006-01-06 990.1395 0.05 49.50697 47.78845 -9.8605073
2006-01-17 988.4210 0.05 49.42105 47.39025 -11.5790356
2006-04-20 986.3902 0.05 49.31951 48.40329 -13.6098383
2006-05-16 985.4739 0.05 49.27370 46.87665 -14.5260531
2006-06-07 983.0769 0.05 49.15384 49.34322 -16.9231039
2007-03-05 983.2663 0.05 49.16331 46.73534 -16.7337257
2007-07-27 980.8383 0.05 49.04191 45.99979 -19.1617016
2008-01-17 977.7962 0.05 48.88981 44.04720 -22.2038246
2008-04-14 972.9536 0.05 48.64768 41.45096 -27.0464310
2008-10-07 965.7568 0.05 48.28784 74.96927 -34.2431534
2009-12-28 992.4383 0.05 49.62191 48.99371 -7.5617297
2010-05-27 991.8101 0.05 49.59050 48.59905 -8.1899288
2011-01-31 990.8186 0.05 49.54093 40.94540 -9.1813865
2011-05-25 982.2231 0.05 49.11115 85.03550 -17.7769198
2012-12-05 1018.1474 0.05 50.90737 60.70586 18.1474250
2013-09-04 1027.9459 0.05 51.39730 47.60163 27.9459088
2013-12-16 1024.1502 0.05 51.20751 46.80884 24.1502469
2014-04-15 1019.7516 0.05 50.98758 50.95013 19.7515776
2014-07-23 1019.7141 0.05 50.98571 44.46719 19.7141303
2014-10-09 1013.1956 0.05 50.65978 51.21572 13.1956174
2015-04-28 1013.7516 0.05 50.68758 44.26862 13.7515573
2016-04-19 1007.3326 0.05 50.36663 47.76803 7.3325986
2016-09-28 1004.7340 0.05 50.23670 44.92186 4.7339961
2016-12-21 999.4192 0.05 49.97096 48.02825 -0.5808434
2017-03-15 997.4765 0.05 49.87382 45.91229 -2.5235477
2017-05-25 993.5149 0.05 49.67575 65.35100 -6.4850843
2018-03-26 1009.1902 0.05 50.45951 47.42041 9.1901747
2018-07-23 1006.1511 0.05 50.30755 49.68589 6.1510729
2018-09-04 1005.5294 0.05 50.27647 44.70817 5.5294058
2019-03-25 999.9611 0.05 49.99806 46.89833 -0.0388940
2019-05-10 996.8614 0.05 49.84307 39.74820 -3.1386169
2020-02-27 986.7665 0.05 49.33833 127.02074 -13.2334894
2021-07-19 1064.4489 0.05 53.22245 NA 64.4489247
  • Total returns with no strategy = -18.64$.
  • Total returns with strategy = 64$.

2.4 Instrument 1004

Additional graph: better strategy performance with longer moving averages. MA1 = 147, MA2 = 300 days.

Investment_from Total_portfolio Investment_percent investment_money total_saved Strategy_returns
2005-03-17 1000.000 0.05 50.00000 50.00000 0.000000
2005-04-13 1000.000 0.05 50.00000 51.19539 0.000000
2005-04-21 1001.195 0.05 50.05977 50.72691 1.195394
2005-07-21 1001.863 0.05 50.09313 51.01329 1.862538
2005-08-22 1002.783 0.05 50.13913 49.46843 2.782697
2005-10-31 1002.112 0.05 50.10560 50.58090 2.111992
2005-11-14 1002.587 0.05 50.12936 50.81837 2.587293
2005-11-28 1003.276 0.05 50.16381 50.90742 3.276300
2006-01-30 1004.020 0.05 50.20100 49.92212 4.019901
2006-02-09 1003.741 0.05 50.18705 50.72501 3.741027
2006-02-16 1004.279 0.05 50.21395 50.41705 4.278989
2006-05-02 1004.482 0.05 50.22410 50.68040 4.482091
2006-07-07 1004.938 0.05 50.24692 51.57668 4.938388
2006-07-19 1006.268 0.05 50.31341 50.70989 6.268151
2006-09-26 1006.665 0.05 50.33323 53.81804 6.664632
2006-10-23 1010.149 0.05 50.50747 50.33960 10.149445
2007-03-20 1009.982 0.05 50.49908 51.88958 9.981569
2007-05-31 1011.372 0.05 50.56860 51.66562 11.372075
2007-06-27 1012.469 0.05 50.62345 51.64502 12.469094
2007-09-07 1013.491 0.05 50.67453 53.99534 13.490662
2008-01-09 1016.811 0.05 50.84057 51.29813 16.811469
2008-03-13 1017.269 0.05 50.86345 53.54272 17.269023
2008-03-20 1019.948 0.05 50.99741 45.84730 19.948288
2008-08-04 1014.798 0.05 50.73991 52.97921 14.798176
2008-09-12 1017.037 0.05 50.85187 52.85213 17.037475
2008-10-03 1019.038 0.05 50.95189 46.47794 19.037733
2008-12-01 1014.564 0.05 50.72819 52.77250 14.563788
2009-01-02 1016.608 0.05 50.83041 49.31470 16.608103
2009-03-19 1015.092 0.05 50.75462 53.32871 15.092402
2009-05-15 1017.666 0.05 50.88332 51.44967 17.666497
2009-08-24 1018.233 0.05 50.91164 51.20446 18.232840
2009-08-28 1018.526 0.05 50.92628 51.86642 18.525658
2009-09-03 1019.466 0.05 50.97329 52.50224 19.465797
2009-11-09 1020.995 0.05 51.04974 49.58313 20.994747
2010-02-22 1019.528 0.05 50.97641 53.14567 19.528142
2010-03-22 1021.697 0.05 51.08487 50.01037 21.697406
2010-06-17 1020.623 0.05 51.03115 53.25158 20.622906
2010-07-12 1022.843 0.05 51.14217 52.22141 22.843338
2011-02-17 1023.923 0.05 51.19613 53.63855 23.922577
2011-03-25 1026.365 0.05 51.31825 52.22598 26.364998
2011-06-30 1027.273 0.05 51.36364 52.21751 27.272731
2011-08-18 1028.127 0.05 51.40633 51.54781 28.126604
2011-08-24 1028.268 0.05 51.41340 51.54034 28.268085
2011-10-28 1028.395 0.05 51.41975 51.82428 28.395019
2011-12-08 1028.800 0.05 51.43998 52.16567 28.799544
2012-02-08 1029.525 0.05 51.47626 53.09213 29.525233
2012-06-15 1031.141 0.05 51.55705 52.27386 31.141098
2012-09-19 1031.858 0.05 51.59290 51.17543 31.857901
2012-09-28 1031.440 0.05 51.57202 50.91945 31.440433
2012-11-26 1030.788 0.05 51.53939 51.79067 30.787866
2013-01-08 1031.039 0.05 51.55196 52.48836 31.039140
2013-01-17 1031.976 0.05 51.59878 52.18493 31.975546
2013-01-30 1032.562 0.05 51.62809 52.12516 32.561703
2013-07-10 1033.059 0.05 51.65294 51.30274 33.058782
2013-09-18 1032.709 0.05 51.63543 52.62742 32.708582
2013-10-21 1033.701 0.05 51.68503 52.76388 33.700576
2013-12-24 1034.779 0.05 51.73897 50.31746 34.779430
2014-03-10 1033.358 0.05 51.66790 52.18699 33.357918
2014-08-20 1033.877 0.05 51.69385 54.09903 33.877011
2014-11-11 1036.282 0.05 51.81411 53.18413 36.282189
2014-12-30 1037.652 0.05 51.88261 53.22999 37.652213
2015-01-08 1039.000 0.05 51.94998 53.46553 38.999595
2015-02-27 1040.515 0.05 52.02576 52.63768 40.515143
2015-04-10 1041.127 0.05 52.05635 52.72636 41.127068
2015-04-23 1041.797 0.05 52.08985 52.40841 41.797077
2015-05-04 1042.116 0.05 52.10578 52.03969 42.115638
2015-05-11 1042.050 0.05 52.10248 53.80292 42.049542
2015-07-14 1043.750 0.05 52.18750 52.54649 43.749982
2015-09-28 1044.109 0.05 52.20545 53.00179 44.108975
2015-11-20 1044.905 0.05 52.24527 53.98889 44.905313
2016-02-01 1046.649 0.05 52.33245 54.40798 46.648933
2016-05-13 1048.724 0.05 52.43622 53.93943 48.724465
2016-06-08 1050.228 0.05 52.51138 54.47795 50.227667
2016-07-05 1052.194 0.05 52.60971 51.39915 52.194234
2016-10-25 1050.984 0.05 52.54918 53.13162 50.983671
2016-11-08 1051.566 0.05 52.57831 54.11963 51.566111
2016-12-12 1053.107 0.05 52.65537 53.78366 53.107431
2017-01-25 1054.236 0.05 52.71179 53.95658 54.235716
2017-02-27 1055.481 0.05 52.77403 53.80838 55.480509
2017-07-25 1056.515 0.05 52.82574 53.34869 56.514867
2017-09-05 1057.038 0.05 52.85189 54.19350 57.037814
2017-10-11 1058.379 0.05 52.91897 54.30391 58.379423
2017-11-10 1059.764 0.05 52.98822 53.91217 59.764365
2017-12-05 1060.688 0.05 53.03442 54.29910 60.688322
2017-12-15 1061.953 0.05 53.09765 53.69414 61.953002
2018-01-08 1062.549 0.05 53.12747 52.66114 62.549488
2018-04-06 1062.083 0.05 53.10416 53.41467 62.083154
2018-05-31 1062.394 0.05 53.11968 54.13770 62.393664
2018-09-13 1063.412 0.05 53.17058 55.43793 63.411682
2018-10-24 1065.679 0.05 53.28395 53.13895 65.679032
2019-01-24 1065.534 0.05 53.27670 54.50162 65.534027
2019-01-31 1066.759 0.05 53.33795 56.01342 66.758947
2019-03-26 1069.434 0.05 53.47172 53.43196 69.434422
2019-10-22 1069.395 0.05 53.46973 53.95024 69.394662
2019-11-01 1069.875 0.05 53.49376 54.44250 69.875171
2019-11-27 1070.824 0.05 53.54120 49.06327 70.823911
2020-04-14 1066.346 0.05 53.31730 55.50856 66.345985
2020-04-29 1068.537 0.05 53.42686 55.73440 68.537248
2020-05-28 1070.845 0.05 53.54224 56.21577 70.844786
2020-07-17 1073.518 0.05 53.67592 55.28570 73.518315
2020-10-09 1075.128 0.05 53.75640 60.42684 75.128099
2020-11-10 1081.799 0.05 54.08993 54.15462 81.798529
2021-02-16 1081.863 0.05 54.09316 55.83718 81.863219
2021-07-14 1083.607 0.05 54.18036 53.00709 83.607234
2021-10-18 1082.434 0.05 54.12170 54.49139 82.433962
2021-10-20 1082.804 0.05 54.14018 58.65221 82.803649
2021-12-13 1087.316 0.05 54.36578 57.30247 87.315674
2022-03-25 1090.252 0.05 54.51262 57.40094 90.252365
2022-06-24 1093.141 0.05 0.00000 NA 93.140687
  • Total returns with no strategy = 201.75$.
  • Total returns with strategy = 93.14$.

2.5 Instrument 1005

Additional graph: better strategy performance with longer moving averages. MA1 = 147, MA2 = 300 days.

Investment_from Total_portfolio Investment_percent investment_money total_saved Strategy_returns
2005-02-22 1000.0000 0.05 50.00000 51.19625 0.0000000
2005-02-23 1001.1962 0.05 50.05981 49.30098 1.1962469
2005-03-10 1000.4374 0.05 50.02187 51.20955 0.4374100
2005-04-04 1001.6251 0.05 50.08125 50.25739 1.6250873
2005-04-21 1001.8012 0.05 50.09006 50.99797 1.8012234
2005-06-01 1002.7091 0.05 50.13546 49.69455 2.7091336
2005-08-05 1002.2682 0.05 50.11341 50.48432 2.2682227
2005-09-16 1002.6391 0.05 50.13196 49.80098 2.6391314
2005-10-10 1002.3081 0.05 50.11541 52.57864 2.3081499
2005-12-13 1004.7714 0.05 50.23857 49.42030 4.7713850
2006-01-03 1003.9531 0.05 50.19766 49.25149 3.9531109
2006-01-20 1003.0069 0.05 50.15035 50.66760 3.0069444
2006-03-03 1003.5242 0.05 50.17621 48.49449 3.5241999
2006-03-16 1001.8425 0.05 50.09212 48.06603 1.8424808
2006-05-05 999.8164 0.05 49.99082 50.91218 -0.1836113
2006-07-18 1000.7378 0.05 50.03689 51.13641 0.7377532
2006-08-02 1001.8373 0.05 50.09186 51.39098 1.8372766
2006-09-15 1003.1364 0.05 50.15682 50.42460 3.1363922
2006-10-13 1003.4042 0.05 50.17021 50.04340 3.4041677
2006-11-15 1003.2774 0.05 50.16387 50.11654 3.2773565
2006-11-22 1003.2300 0.05 50.16150 49.79833 3.2300302
2006-11-28 1002.8669 0.05 50.14334 49.98614 2.8668538
2007-01-08 1002.7097 0.05 50.13548 50.03523 2.7096550
2007-01-31 1002.6094 0.05 50.13047 49.41041 2.6094018
2007-02-07 1001.8893 0.05 50.09447 49.96318 1.8893402
2007-02-22 1001.7580 0.05 50.08790 49.69534 1.7580496
2007-04-09 1001.3655 0.05 50.06827 49.89787 1.3654873
2007-04-27 1001.1951 0.05 50.05975 49.59057 1.1950871
2007-05-02 1000.7259 0.05 50.03629 49.71315 0.7258980
2007-06-08 1000.4028 0.05 50.02014 56.21411 0.4027563
2007-10-31 1006.5967 0.05 50.32984 51.32147 6.5967316
2007-12-19 1007.5884 0.05 50.37942 49.66344 7.5883690
2008-01-03 1006.8724 0.05 50.34362 50.24539 6.8723912
2008-03-05 1006.7742 0.05 50.33871 50.89021 6.7741601
2008-04-17 1007.3257 0.05 50.36628 49.64954 7.3256641
2008-05-22 1006.6089 0.05 50.33045 49.08166 6.6089257
2008-06-19 1005.3601 0.05 50.26801 53.71718 5.3601364
2008-09-22 1008.8093 0.05 50.44047 47.36389 8.8093054
2008-10-08 1005.7327 0.05 50.28664 49.78106 5.7327275
2008-11-18 1005.2272 0.05 50.26136 47.57345 5.2271511
2008-11-20 1002.5392 0.05 50.12696 48.76178 2.5392478
2008-12-02 1001.1741 0.05 50.05870 48.51282 1.1740680
2009-01-12 999.6282 0.05 49.98141 49.63790 -0.3718184
2009-03-23 999.2847 0.05 49.96423 55.11713 -0.7153311
2009-06-11 1004.4376 0.05 50.22188 51.07899 4.4375622
2009-08-06 1005.2947 0.05 50.26473 49.68243 5.2946791
2009-09-04 1004.7124 0.05 50.23562 58.47504 4.7123754
2009-12-10 1012.9518 0.05 50.64759 50.11833 12.9517939
2009-12-18 1012.4225 0.05 50.62113 51.38714 12.4225327
2010-01-19 1013.1885 0.05 50.65943 50.54211 13.1885484
2010-01-22 1013.0712 0.05 50.65356 51.96126 13.0712300
2010-03-12 1014.3789 0.05 50.71895 50.58331 14.3789292
2010-04-01 1014.2433 0.05 50.71216 50.26477 14.2432923
2010-04-30 1013.7959 0.05 50.68980 50.13052 13.7959010
2010-05-21 1013.2366 0.05 50.66183 50.81012 13.2366229
2010-06-15 1013.3849 0.05 50.66925 51.10814 13.3849124
2010-06-17 1013.8238 0.05 50.69119 50.22872 13.8238091
2010-06-22 1013.3613 0.05 50.66807 49.33629 13.3613354
2010-08-04 1012.0296 0.05 50.60148 50.41659 12.0295595
2010-09-30 1011.8447 0.05 50.59223 51.90827 11.8446700
2010-11-17 1013.1607 0.05 50.65804 51.27461 13.1607109
2011-01-11 1013.7773 0.05 50.68886 49.23205 13.7772816
2011-01-31 1012.3205 0.05 50.61602 50.11525 12.3204670
2011-02-17 1011.8197 0.05 50.59098 55.48225 11.8196960
2011-05-31 1016.7110 0.05 50.83555 50.53699 16.7109646
2011-06-02 1016.4124 0.05 50.82062 49.73141 16.4124058
2011-07-26 1015.3232 0.05 50.76616 51.62708 15.3231977
2011-09-12 1016.1841 0.05 50.80921 49.00115 16.1841129
2011-09-23 1014.3761 0.05 50.71880 50.52526 14.3760601
2011-11-02 1014.1825 0.05 50.70913 52.06188 14.1825166
2012-01-12 1015.5353 0.05 50.77676 49.75474 15.5352734
2012-01-24 1014.5133 0.05 50.72566 52.63018 14.5132506
2012-03-29 1016.4178 0.05 50.82089 51.04818 16.4177655
2012-04-05 1016.6451 0.05 50.83225 50.54317 16.6450596
2012-04-10 1016.3560 0.05 50.81780 48.88928 16.3559720
2012-04-30 1014.4274 0.05 50.72137 49.04336 14.4274497
2012-06-20 1012.7494 0.05 50.63747 56.67775 12.7494368
2012-10-10 1018.7897 0.05 50.93949 50.19162 18.7897115
2012-10-24 1018.0418 0.05 50.90209 48.97468 18.0418423
2012-11-08 1016.1144 0.05 50.80572 51.02505 16.1144292
2012-12-20 1016.3338 0.05 50.81669 57.02429 16.3337577
2013-03-19 1022.5414 0.05 51.12707 51.28350 22.5413638
2013-04-26 1022.6978 0.05 51.13489 50.47768 22.6977974
2013-06-03 1022.0406 0.05 51.10203 49.95325 22.0405889
2013-06-21 1020.8918 0.05 51.04459 52.39725 20.8918131
2013-08-16 1022.2445 0.05 51.11222 49.75407 22.2444755
2013-09-26 1020.8863 0.05 51.04432 54.02409 20.8863211
2013-12-05 1023.8661 0.05 51.19330 51.41979 23.8660929
2013-12-11 1024.0926 0.05 51.20463 50.31470 24.0925789
2014-03-06 1023.2027 0.05 51.16013 51.75292 23.2026541
2014-03-24 1023.7954 0.05 51.18977 52.07664 23.7954439
2014-05-15 1024.6823 0.05 51.23412 51.04448 24.6823154
2014-07-28 1024.4927 0.05 51.22463 53.16135 24.4926772
2014-10-02 1026.4294 0.05 51.32147 51.55548 26.4293982
2014-10-14 1026.6634 0.05 51.33317 54.43376 26.6634057
2014-12-16 1029.7640 0.05 51.48820 50.39128 29.7639917
2015-01-05 1028.6671 0.05 51.43335 47.83581 28.6670678
2015-01-28 1025.0695 0.05 51.25348 49.76170 25.0695280
2015-03-27 1023.5777 0.05 51.17889 50.25815 23.5777487
2015-04-24 1022.6570 0.05 51.13285 50.58856 22.6570139
2015-05-22 1022.1127 0.05 51.10564 51.23725 22.1127250
2015-06-16 1022.2443 0.05 51.11222 49.53611 22.2443377
2015-06-30 1020.6682 0.05 51.03341 51.39358 20.6682297
2015-07-28 1021.0284 0.05 51.05142 55.30345 21.0283972
2015-11-11 1025.2804 0.05 51.26402 51.18979 25.2804248
2015-12-01 1025.2062 0.05 51.26031 52.64971 25.2061903
2016-01-06 1026.5956 0.05 51.32978 54.55716 26.5955901
2016-03-01 1029.8230 0.05 51.49115 50.57119 29.8229739
2016-03-15 1028.9030 0.05 51.44515 51.15542 28.9030108
2016-04-14 1028.6133 0.05 51.43066 49.71997 28.6132820
2016-04-21 1026.9026 0.05 51.34513 49.85043 26.9025922
2016-05-18 1025.4079 0.05 51.27039 51.80478 25.4078887
2016-06-28 1025.9423 0.05 51.29711 52.26083 25.9422748
2016-07-29 1026.9060 0.05 51.34530 52.36627 26.9059912
2016-09-12 1027.9270 0.05 51.39635 51.46611 27.9269628
2016-10-14 1027.9967 0.05 51.39984 51.30512 27.9967236
2016-11-07 1027.9020 0.05 51.39510 49.64738 27.9020061
2016-11-10 1026.1543 0.05 51.30771 51.86006 26.1542883
2017-01-04 1026.7066 0.05 51.33533 50.54473 26.7066350
2017-01-11 1025.9160 0.05 51.29580 54.40004 25.9160293
2017-03-09 1029.0203 0.05 51.45101 51.05611 29.0202729
2017-03-27 1028.6254 0.05 51.43127 50.99268 28.6253722
2017-04-24 1028.1868 0.05 51.40934 51.34506 28.1867832
2017-04-27 1028.1225 0.05 51.40613 51.27060 28.1224999
2017-06-29 1027.9870 0.05 51.39935 53.94164 27.9869734
2017-09-25 1030.5293 0.05 51.52646 48.63427 30.5292685
2017-10-23 1027.6371 0.05 51.38185 52.64618 27.6370775
2018-01-04 1028.9014 0.05 51.44507 49.24585 28.9013991
2018-01-25 1026.7022 0.05 51.33511 51.84485 26.7021829
2018-04-03 1027.2119 0.05 51.36060 50.93259 27.2119278
2018-04-13 1026.7839 0.05 51.33920 48.52078 26.7839252
2018-04-20 1023.9655 0.05 51.19828 58.00834 23.9655113
2018-09-07 1030.7756 0.05 51.53878 51.34138 30.7755807
2018-09-28 1030.5782 0.05 51.52891 50.84621 30.5781784
2018-10-04 1029.8955 0.05 51.49477 54.14836 29.8954844
2018-12-20 1032.5491 0.05 51.62745 51.34748 32.5490705
2019-01-11 1032.2691 0.05 51.61345 51.66872 32.2690960
2019-01-17 1032.3244 0.05 51.61622 54.09424 32.3243629
2019-01-23 1034.8024 0.05 51.74012 54.13069 34.8023848
2019-03-08 1037.1930 0.05 51.85965 55.20110 37.1929559
2019-04-26 1040.5344 0.05 52.02672 52.71174 40.5344066
2019-05-10 1041.2194 0.05 52.06097 51.16802 41.2194282
2019-05-29 1040.3265 0.05 52.01632 55.26226 40.3264800
2019-07-26 1043.5724 0.05 52.17862 51.48435 43.5724179
2019-08-06 1042.8781 0.05 52.14391 55.36774 42.8781441
2019-10-04 1046.1020 0.05 52.30510 51.61822 46.1019733
2019-10-09 1045.4151 0.05 52.27075 50.50813 45.4150900
2019-11-06 1043.6525 0.05 52.18262 51.83421 43.6524673
2019-11-25 1043.3040 0.05 52.16520 52.58933 43.3040499
2020-01-03 1043.7282 0.05 52.18641 52.66483 43.7281724
2020-02-13 1044.2066 0.05 52.21033 50.04690 44.2065948
2020-02-25 1042.0432 0.05 52.10216 55.49432 42.0431633
2020-04-29 1045.4353 0.05 52.27177 52.95766 45.4353250
2020-06-25 1046.1212 0.05 52.30606 53.51239 46.1212202
2020-06-29 1047.3276 0.05 52.36638 61.05071 47.3275503
2020-09-09 1056.0119 0.05 52.80059 53.31832 56.0118843
2020-09-11 1056.5296 0.05 52.82648 52.34636 56.5296082
2020-09-18 1056.0495 0.05 52.80247 52.51087 56.0494921
2020-10-29 1055.7579 0.05 52.78789 51.58645 55.7578920
2020-11-10 1054.5564 0.05 52.72782 51.81402 54.5564429
2020-11-20 1053.6426 0.05 52.68213 52.19975 53.6426448
2020-12-23 1053.1603 0.05 52.65801 52.34226 53.1602614
2021-01-13 1052.8445 0.05 52.64223 54.78662 52.8445093
2021-04-26 1054.9889 0.05 52.74945 51.77757 54.9889077
2021-06-01 1054.0170 0.05 52.70085 56.22058 54.0170295
2021-08-27 1057.5368 0.05 52.87684 52.47710 57.5367566
2021-09-21 1057.1370 0.05 52.85685 53.27950 57.1370192
2021-10-13 1057.5597 0.05 52.87798 51.30665 57.5596658
2021-10-21 1055.9883 0.05 52.79942 54.68700 55.9883364
2021-12-02 1057.8759 0.05 52.89380 55.34783 57.8759146
2022-01-12 1060.3299 0.05 53.01650 51.92418 60.3299444
2022-01-27 1059.2376 0.05 52.96188 53.92094 59.2376320
2022-02-02 1060.1967 0.05 53.00983 50.39480 60.1966877
2022-02-11 1057.5816 0.05 52.87908 55.32534 57.5816498
2022-05-04 1060.0279 0.05 53.00140 NA 60.0279110
  • Total returns with no strategy = 116.2$.
  • Total returns with strategy = 60.03$.

2.6 Instrument 1006

Additional graph: better strategy performance with longer moving averages. MA1 = 147, MA2 = 300 days.

Investment_from Total_portfolio Investment_percent investment_money total_saved Strategy_returns
2010-07-26 1000.0000 0.05 50.00000 49.47444 0.0000000
2010-08-02 999.4744 0.05 49.97372 44.86407 -0.5255614
2010-08-09 994.3648 0.05 49.71824 50.47155 -5.6352083
2010-09-24 995.1181 0.05 49.75590 45.35572 -4.8819017
2010-10-11 990.7179 0.05 49.53590 68.64525 -9.2820837
2010-12-15 1009.8273 0.05 50.49136 40.22749 9.8272693
2010-12-27 999.5634 0.05 49.97817 47.08351 -0.4366001
2011-03-16 996.6687 0.05 49.83344 51.90594 -3.3312633
2011-05-19 998.7412 0.05 49.93706 46.81376 -1.2587599
2011-06-16 995.6179 0.05 49.78090 46.74336 -4.3820572
2011-07-18 992.5804 0.05 49.62902 47.45796 -7.4195945
2011-07-28 990.4093 0.05 49.52047 48.14490 -9.5906522
2011-08-03 989.0338 0.05 49.45169 45.41149 -10.9662207
2011-10-04 984.9936 0.05 49.24968 55.49028 -15.0064227
2011-12-13 991.2342 0.05 49.56171 54.19818 -8.7658187
2012-04-10 995.8707 0.05 49.79353 41.62728 -4.1293468
2012-07-25 987.7044 0.05 49.38522 48.52267 -12.2956041
2012-08-28 986.8418 0.05 49.34209 43.02630 -13.1581541
2012-09-27 980.5261 0.05 49.02630 48.77574 -19.4739420
2012-10-08 980.2755 0.05 49.01377 52.67036 -19.7245023
2012-12-31 983.9321 0.05 49.19660 47.80679 -16.0679191
2013-01-10 982.5423 0.05 49.12711 50.28650 -17.4577338
2013-02-22 983.7016 0.05 49.18508 44.71022 -16.2983507
2013-03-19 979.2268 0.05 48.96134 221.72309 -20.7732087
2013-10-10 1151.9885 0.05 57.59943 50.93511 151.9885442
2013-10-23 1145.3242 0.05 57.26621 66.76008 145.3242250
2014-01-14 1154.8181 0.05 57.74090 77.67388 154.8180942
2014-03-25 1174.7511 0.05 58.73755 50.34324 174.7510721
2014-05-08 1166.3568 0.05 58.31784 61.16919 166.3567541
2014-07-11 1169.2081 0.05 58.46041 68.15634 169.2081109
2014-09-18 1178.9040 0.05 58.94520 55.42887 178.9040462
2014-10-13 1175.3877 0.05 58.76939 56.80788 175.3877114
2014-12-02 1173.4262 0.05 58.67131 55.72680 173.4262014
2015-01-06 1170.4817 0.05 58.52408 54.69566 170.4816962
2015-02-17 1166.6533 0.05 58.33266 57.54229 166.6532679
2015-02-25 1165.8629 0.05 58.29314 56.98329 165.8628907
2015-03-26 1164.5530 0.05 58.22765 74.42601 164.5530334
2015-07-14 1180.7514 0.05 59.03757 59.61712 180.7513870
2015-07-28 1181.3309 0.05 59.06655 61.11006 181.3309354
2015-09-08 1183.3744 0.05 59.16872 56.89300 183.3744480
2015-10-01 1181.0987 0.05 59.05494 52.20456 181.0987279
2015-11-13 1174.2484 0.05 58.71242 55.63033 174.2483553
2015-12-14 1171.1663 0.05 58.55831 54.24654 171.1662651
2016-01-07 1166.8545 0.05 58.34272 71.20051 166.8544962
2016-05-03 1179.7123 0.05 58.98561 58.56381 179.7122784
2016-06-15 1179.2905 0.05 58.96452 61.22575 179.2904728
2016-08-17 1181.5517 0.05 59.07758 58.58977 181.5516977
2016-09-30 1181.0639 0.05 59.05319 55.98911 181.0638801
2016-10-10 1177.9998 0.05 58.89999 54.71064 177.9997993
2016-11-01 1173.8105 0.05 58.69052 54.27386 173.8104542
2016-12-02 1169.3938 0.05 58.46969 76.07775 169.3937883
2017-02-28 1187.0018 0.05 59.35009 70.50877 187.0018458
2017-05-24 1198.1605 0.05 59.90803 59.81600 198.1605267
2017-07-05 1198.0685 0.05 59.90343 59.00139 198.0685021
2017-08-23 1197.1665 0.05 59.85832 59.09916 197.1664633
2017-08-28 1196.4073 0.05 59.82037 59.09075 196.4073030
2017-09-07 1195.6777 0.05 59.78388 63.27939 195.6776836
2017-09-11 1199.1732 0.05 59.95866 57.13026 199.1731861
2017-09-26 1196.3448 0.05 59.81724 57.64455 196.3447914
2017-10-23 1194.1721 0.05 59.70860 55.20933 194.1720996
2017-12-28 1189.6728 0.05 59.48364 60.99293 189.6728229
2018-02-07 1191.1821 0.05 59.55911 58.66383 191.1821093
2018-02-09 1190.2868 0.05 59.51434 56.04941 190.2868379
2018-03-07 1186.8219 0.05 59.34110 58.16349 186.8219039
2018-04-23 1185.6443 0.05 59.28221 58.36244 185.6442981
2018-05-03 1184.7245 0.05 59.23623 56.21357 184.7245225
2018-05-16 1181.7019 0.05 59.08509 61.80019 181.7018655
2018-07-05 1184.4170 0.05 59.22085 52.45495 184.4169663
2018-08-20 1177.6511 0.05 58.88255 50.44367 177.6510633
2018-09-28 1169.2122 0.05 58.46061 59.08613 169.2121788
2018-12-20 1169.8377 0.05 58.49188 50.45568 169.8376972
2019-01-22 1161.8015 0.05 58.09007 54.79707 161.8014942
2019-04-05 1158.5085 0.05 57.92542 64.91623 158.5084874
2019-07-29 1165.4993 0.05 58.27496 59.80223 165.4992965
2019-10-07 1167.0266 0.05 58.35133 185.03988 167.0265580
2020-03-02 1293.7151 0.05 64.68576 140.53890 293.7151111
2020-08-11 1369.5683 0.05 68.47841 78.65594 369.5682552
2020-09-10 1379.7458 0.05 68.98729 60.90526 379.7457808
2020-09-24 1371.6637 0.05 68.58319 69.14732 371.6637497
2020-10-27 1372.2279 0.05 68.61139 67.44791 372.2278829
2020-11-11 1371.0644 0.05 68.55322 123.78369 371.0644020
2021-02-16 1426.2949 0.05 71.31474 75.30260 426.2948676
2021-04-30 1430.2827 0.05 71.51414 76.24182 430.2827236
2021-07-20 1435.0104 0.05 71.75052 70.50335 435.0104074
2021-07-23 1433.7632 0.05 71.68816 72.47234 433.7632394
2021-07-28 1434.5474 0.05 71.72737 70.96793 434.5474216
2021-08-20 1433.7880 0.05 71.68940 102.51493 433.7879823
2021-12-06 1464.6135 0.05 73.23068 66.90210 464.6135104
2022-01-19 1458.2849 0.05 72.91425 79.26894 458.2849335
2022-04-25 1464.6396 0.05 73.23198 NA 464.6396300
  • Total returns with no strategy = 680.99$.
  • Total returns with strategy = 464.64$.

2.7 Instrument 1007

Investment_from Total_portfolio Investment_percent investment_money total_saved Strategy_returns
2009-12-16 1000.0000 0.05 50.00000 59.06976 0.000000
2012-12-19 1009.0698 0.05 50.45349 50.08293 9.069764
2013-12-18 1008.6992 0.05 50.43496 51.02606 8.699202
2014-03-12 1009.2903 0.05 50.46452 45.23075 9.290303
2014-12-17 1004.0565 0.05 50.20283 55.25623 4.056533
2018-02-23 1009.1099 0.05 50.45550 36.05840 9.109940
2009-03-17 994.7128 0.05 49.73564 57.77574 -5.287161
2010-05-17 1002.7529 0.05 50.13765 53.04810 2.752935
2012-03-23 1005.6634 0.05 50.28317 49.87825 5.663393
2013-05-08 1005.2585 0.05 50.26292 41.26557 5.258476
2015-03-18 996.2611 0.05 49.81306 49.22641 -3.738878
2016-04-28 995.6745 0.05 49.78372 48.45997 -4.325521
2017-04-27 994.3507 0.05 49.71754 49.76372 -5.649280
2018-04-30 994.3969 0.05 49.71985 48.36131 -5.603092
2018-06-15 993.0384 0.05 49.65192 66.53019 -6.961630
2008-08-13 1009.9166 0.05 50.49583 63.25012 9.916643
2011-08-15 1022.6709 0.05 51.13355 50.83922 22.670935
2011-08-19 1022.3766 0.05 51.11883 50.57101 22.376611
2011-09-15 1021.8288 0.05 51.09144 50.48933 21.828789
2012-08-31 1021.2267 0.05 51.06133 44.34096 21.226676
2013-06-19 1014.5063 0.05 50.72532 50.60462 14.506300
2014-08-07 1014.3856 0.05 50.71928 49.93180 14.385604
2014-09-10 1013.5981 0.05 50.67991 50.79481 13.598120
2016-09-15 1013.7130 0.05 50.68565 48.51143 13.713024
2018-06-20 1011.5388 0.05 50.57694 48.78641 11.538806
2008-10-09 1009.7483 0.05 50.48741 56.50998 9.748278
2010-12-01 1015.7708 0.05 50.78854 49.65748 15.770846
2011-09-30 1014.6398 0.05 50.73199 48.93808 14.639788
2011-11-22 1012.8459 0.05 50.64229 49.31844 12.845877
2011-12-15 1011.5220 0.05 50.57610 46.20073 11.522022
2013-09-18 1007.1467 0.05 50.35733 50.30928 7.146654
2016-11-18 1007.0986 0.05 50.35493 48.40148 7.098603
2017-11-02 1005.1452 0.05 50.25726 49.27035 5.145155
2018-12-13 1004.1582 0.05 50.20791 55.14029 4.158244
2020-12-14 1009.0906 0.05 0.00000 NA 9.090617
  • Total returns with no strategy = -7.2$.
  • Total returns with strategy = 9.09$.

3 Some comments on results

By using EMA strategy, strategy returns are performing better than total returns on instruments that do not fluctuate a lot and are not drastically growing/shrinking. It is clear that MA strategy works on short-term investments only.

In order to generate better techniques for the whole portfolio, it is important to get the track from a specific date for all instruments at the same time. Then it is possible to work with the portfolio as desired. At this time, we have not looked at the general view, how one instrument’s strategy impacts the other ones and so on.